package com.service.xsxt;

import com.dao.xsxt.DormMapper;
import com.entity.common.ApiResult;
import com.entity.xsxt.Dorm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by System on 2019/04/15 09:13:54.
 */
@Service
public class DormService {

    @Autowired
    private DormMapper dormMapper;

    public List<Dorm> getPageList(Dorm dorm){
        return dormMapper.getPageList(dorm);
    }

    public ApiResult addDorm(Dorm dorm) {
        int num = dormMapper.insertSelective(dorm);
        return  new ApiResult(num);
    }

    public ApiResult getDormById(Long id) {
        Dorm dorm = dormMapper.selectByPrimaryKey(id);
        return new ApiResult(true,"获取数据成功！",dorm);
    }

    public ApiResult editDorm(Dorm dorm) {
        int num = dormMapper.updateByPrimaryKeySelective(dorm);
        return  new ApiResult(num);
    }

    public ApiResult deleteDorm(Long id) {
        int num = dormMapper.deleteByPrimaryKey(id);
        return  new ApiResult(num);
    }
}
